package com.itheima.controller;

import com.itheima.common.constant.MessageConstant;
import com.itheima.common.entity.Result;
import com.itheima.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
@Slf4j
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/getLoginUsername")
    public Result getLoginUsername(){
        String username = userService.findByUsername("admin").getUsername();
        log.info("获取当前登录用户名");
        return new Result(true, MessageConstant.GET_USERNAME_SUCCESS, username);
    }
}
